﻿Imports Microsoft.VisualBasic

Namespace My
    Public Class MyTreeNode
        Inherits TreeNode

        Public Sub New()

        End Sub

        Public Sub New(ByVal text As String)
            Me.MyText = text
        End Sub

        Private foreColorField As Drawing.Color = Drawing.Color.Blue

        Public Property ForeColor() As Drawing.Color
            Get
                Return Me.foreColorField
            End Get
            Set(ByVal value As Drawing.Color)
                Me.foreColorField = value
            End Set
        End Property

        Private backColorField As Drawing.Color = Drawing.Color.White

        Public Property BackColor() As Drawing.Color
            Get
                Return Me.backColorField
            End Get
            Set(ByVal value As Drawing.Color)
                Me.backColorField = value
            End Set
        End Property

        Private myTextField As String

        Public Property MyText() As String
            Get
                Return Me.myTextField
            End Get
            Set(ByVal value As String)
                Dim s As New StringBuilder

                's.AppendFormat("<span oncontextmenu='TreeView_SelectNode(ctl00_ContentPlaceHolder1_trOrganization_Data,this,this.id); return showmenuie5(event)'>{0}</span>", value)

                If Me.ContextMenuVisible = True Then
                    If Me.ContextMenuID = "" Then
                        s.AppendFormat("<span oncontextmenu=' this.click(); return showmenuie5(event);' style='background-color:{2};color:{1}'>{0}</span>", value, Drawing.ColorTranslator.ToHtml(Me.ForeColor), Drawing.ColorTranslator.ToHtml(Me.BackColor))
                    Else
                        's.AppendFormat("<span oncontextmenu=' this.click(); return showmenuie5(event);' style='background-color:{2};color:{1}'>{0}</span>", value, Drawing.ColorTranslator.ToHtml(Me.ForeColor), Drawing.ColorTranslator.ToHtml(Me.BackColor))
                        s.AppendFormat("<span oncontextmenu=' this.click(); return showmenuie5(event,""{3}"");' style='background-color:{2};color:{1}'>{0}</span>", value, Drawing.ColorTranslator.ToHtml(Me.ForeColor), Drawing.ColorTranslator.ToHtml(Me.BackColor), Me.ContextMenuID)
                    End If

                Else
                    s.AppendFormat("<span style='background-color:{2};color:{1}'>{0}</span>", value, Drawing.ColorTranslator.ToHtml(Me.ForeColor), Drawing.ColorTranslator.ToHtml(Me.BackColor))
                End If

                Me.Text = s.ToString()
                Me.myTextField = value

            End Set
        End Property

        Private contextMenuVisibleField As Boolean = True

        Public Property ContextMenuVisible() As Boolean
            Get
                Return Me.contextMenuVisibleField
            End Get
            Set(ByVal value As Boolean)
                Me.contextMenuVisibleField = value
            End Set
        End Property

        Private contextMenuIDField As String
        Public Property ContextMenuID() As String
            Get
                Return Me.contextMenuIDField
            End Get
            Set(ByVal value As String)
                Me.contextMenuIDField = value
            End Set
        End Property
    End Class

End Namespace
